# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=openfec
pkgver=1.4.2.9
pkgrel=1
pkgdesc="Open Forward Erasure Codecs"
arch=(loong64 x86_64)
url="http://openfec.org/"
license=(custom:CeCILL-C)
depends=(glibc)
makedepends=(cmake)
provides=(libopenfec.so)
# NOTE: we are using roc-streaming's version, because the original upstream is effectively dead:
# https://github.com/roc-streaming/openfec
source=(https://github.com/roc-streaming/openfec/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('6c23f4d4263c514170f6abf806d7faf4c3fbf7fe34f55128383dcd84808a6966edd13587f7549ead74578ca219bdce9e42a32fc04071df0d54dae5b1336ed2b3')
b2sums=('c3fd234c6f758144e514a262028024cb61a2379d065ab645067200618181a5ba4ae793fda82f60f0a870906d1978ef08ba8e73f9711bccf27b5161c5732702d1')

build() {
  local cmake_options=(
    -B build
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_INSTALL_LIBDIR=lib
    -DBUILD_SHARED_LIBS=ON
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/{LICENCE,Licence}* -t "$pkgdir/usr/share/licenses/$pkgname/"
}
